﻿<%
Sub Head()
	Response.ContentType = "text/vnd.wap.wml; charset=utf-8"
	w "<?xml version=""1.0"" encoding=""utf-8""?>"&_
		"<!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML 1.1//EN"" ""http://www.wapforum.org/DTD/wml_1.1.xml"">"&_
		"<wml>"&_
		"<head>"&_
		"<meta http-equiv=""Cache-Control"" content=""max-age=0""/>"&_
		"<meta http-equiv=""Cache-Control"" content=""no-cache""/>"&_
		"</head>"
End Sub

Sub Head2()
	Response.ContentType = "text/html; charset=utf-8"
	w "<?xml version=""1.0"" encoding=""utf-8""?>"&_
		"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"&_
		"<html xmlns=""http://www.w3.org/1999/xhtml"">"&_
		"<head>"&_
		"<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>"
End Sub

Sub Last()
	Call closeconn()
	w "<br/><a href=""../index.asp?sid="&sid&""">[后台管理]</a></p></card></wml>"
	Response.End
End Sub

Sub Last2()
	Call closeconn()
	w "<br/><a href=""../index.asp?sid="&sid&""">[后台管理]</a></body></html>"
	Response.End
End Sub

Sub rootLast()
	Call closeconn()
	w "<br/><a href=""index.asp?sid="&sid&""">[后台管理]</a></p></card></wml>"
	Response.End
End Sub

Sub rootLast2()
	Call closeconn()
	w "<br/><a href=""index.asp?sid="&sid&""">[后台管理]</a></body></html>"
	Response.End
End Sub

Sub Error(erstr)
	Call closeconn()
	Response.write erstr &"</p></card></wml>"
	Response.end
end Sub

Sub Error2(erstr)
	Call closeconn()
	Response.write erstr &"</body></html>"
	Response.end
end Sub

'生成唯一的sid值，使用时要引用md5以及建立连接
Function onlysid()
	Dim tmp_,count_
	tmp_=md5(md5(hu_randomize,16),32)
	count_=conn.Execute("select count(id) from 74hu_admin where sid='"&tmp_&"'")(0)
	if count_<>0 then tmp_=onlysid()
	onlysid=tmp_
End Function

'时间命名的函数
function addwml(fname)
	fname = fname '前fname为变量，后fname为函数参数引用
	fname = replace(fname,"-","")
	fname = replace(fname," ","")
	fname = replace(fname,":","")
	fname = replace(fname,"PM","")
	fname = replace(fname,"AM","")
	fname = replace(fname,"上午","")
	fname = replace(fname,"下午","")
	addwml = fname & ".wml"
end function

'文件内容读取
Function LoadFile(File)
	Dim objStream
	On Error Resume Next
	Set objStream = Server.CreateObject("ADODB.Stream")
		If Err.Number=-2147221005 Then
		Response.Write "非常遗憾,您的主机不支持ADODB.Stream,不能使用本程序"
		Err.Clear
'		Response.End
		End If
	With objStream
	.Type = 2
	.Mode = 3
	.Open
	.LoadFromFile Server.MapPath(File)
		If Err.Number<>0 Then
		Response.Write "文件"&File&"无法被打开，请检查是否存在!"
		Err.Clear
'		Response.End
		End If
	.Charset = "utf-8"
	.Position = 2
	LoadFile = .ReadText
	.Close
	End With
	Set objStream = Nothing
End Function

'存储内容到文件
Sub SaveToFile(strBody,File)
	Dim objStream
	On Error Resume Next
	Set objStream = Server.CreateObject("ADODB.Stream")
		If Err.Number=-2147221005 Then
		Response.Write "非常遗憾,您的主机不支持ADODB.Stream,不能使用本程序"
		Err.Clear
'		Response.End
		End If
	With objStream
	.Type = 2
	.Open
	.Charset = "utf-8"
	.Position = objStream.Size
	.WriteText = strBody
	.SaveToFile Server.MapPath(File),2
	.Close
	End With
	Set objStream = Nothing
End Sub

'IP封锁
Sub ipLockAdmin(str)
	Dim IpArray,WhyIpLock,IpSQL,IpRS
	IpArray=split(str,".")
	IpSQL="SELECT iplock From 74hu_IpLock Where  "& _
	" (ipsame=4 and ip1="&Cint(IpArray(0))&" and ip2="&Cint(IpArray(1))&" and ip3="&Cint(IpArray(2))&" and ip4="&Cint(IpArray(3))&" )  "& _
	" Or (ipsame=3 and  ip1="&Cint(IpArray(0))&"  and  ip2="&Cint(IpArray(1))&"  and  ip3="&Cint(IpArray(2))&" )   "& _
	" Or (ipsame=2 and ip1="&Cint(IpArray(0))&" and ip2="&Cint(IpArray(1))&" ) Or (ipsame=1 and ip1="&Cint(IpArray(0))&" ) Order By ipid "
	Set IpRS=myConn.execute(IpSQL)
	If Not (IpRS.bof or IpRS.eof) Then
		WhyIpLock=split(IpRS("iplock"),"|")
		Response.write "<card title=""出错了""><p>你使用的IP段或IP地址已被封锁<br/>封锁原因:"&WhyIpLock(1)&"<br/>封锁时间:"&WhyIpLock(0)&"</p></card></wml>"
		Response.End
		Set myConn=nothing
	End If
	Set IpRS=Nothing
End Sub
%>